/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rpgmapper.bo.rules;

import java.util.Map;
import org.rpgmapper.bo.Character;
import org.rpgmapper.bo.Stat;

/**
 *
 * @author Nehon
 */
public class ModifierRule extends Rule {

    private Stat[] stats;
    private Stat targetStat;
    private int miscModifier;

    public ModifierRule(Stat targetStat, int miscModifier, Stat... stats) {
        this.stats = stats;
        this.targetStat = targetStat;
        this.miscModifier = miscModifier;
    }

    public ModifierRule(Stat targetStat, int miscModifier, int duration, Stat... stats) {
        this(targetStat, miscModifier, stats);
        this.duration = duration;
    }

    @Override
    public void apply(Character c) {
        int value = c.getMod(targetStat);

        value += miscModifier;
        if (stats != null) {
            for (Stat stat : stats) {
                value += c.get(stat);
            }
        }
        c.setMod(targetStat, value);
    }
}
